# Appium_Python/pages/BasePage.py
from appium import webdriver
from appium.webdriver.common.appiumby import AppiumBy
from selenium.webdriver.support.wait import WebDriverWait
import allure
class BasePage:
    def __init__(self, driver):
        self.driver = driver
        self.wait = WebDriverWait(self.driver,10)

    @allure.step("定位元素")
    def local_location(self, by, value):
        return self.wait.until(lambda x: x.find_element(by, value))

    @allure.step("点击元素")
    def click(self, by, value):
        self.local_location(by, value).click()

    @allure.step("输入内容")
    def send_keys(self, by, value, text):
        self.local_location(by, value).send_keys(text)

    @allure.step("获得返回文本")
    def get_text(self, name, value):
        el = (name, value)
        result = self.wait.until(
            lambda x: x.find_element(*el).text
        )
        return result